package cn.com.connext.scrm.repository.master;


import cn.com.connext.scrm.domain.master.ActivityModuleConfig;
import cn.com.connext.scrm.domain.master.ActivityModuleConfigChild;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface ActivityModuleConfigChildRepository extends JpaRepository<ActivityModuleConfigChild, Long>, JpaSpecificationExecutor {
    @Query(value = "select * FROM activity_module_config_child where activity_module_config_id= :activityModuleConfigId",nativeQuery = true)
    List<ActivityModuleConfigChild> findByActivityModuleConfigId(@Param("activityModuleConfigId") Long activityModuleConfigId);

    @Modifying
    @Query(value = "delete FROM activity_module_config_child where activity_module_config_id= :activityModuleConfigId",nativeQuery = true)
    void deleteByActivityModuleConfigId(@Param("activityModuleConfigId")Long activityModuleConfigId);

    List<ActivityModuleConfigChild> ActivityModuleConfigId(@Param("activityModuleConfigId")Long activityModuleConfigId);
    @Modifying
    @Query(value = "delete from activity_module_config_child where  id  not in :list and activity_module_config_id= :activityModuleConfigId ", nativeQuery = true)
    void deleteByCondition(@Param("list")List<Long> idList,@Param("activityModuleConfigId")Long activityModuleConfigId);
}
